package com.zjitc.service;

import com.zjitc.common.PageModel;
import com.zjitc.common.ServerResponse;
import com.zjitc.pojo.Caritem;
import com.zjitc.pojo.Orderitems;
import com.zjitc.pojo.Orders;
import com.zjitc.pojo.User;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.TimeoutException;
import javax.servlet.http.HttpSession;

/**
 * @author Administrator
 */
public interface OrderService {

  /**
   * 分页查看订单
   * @param uid
   * @param pageid
   * @return
   */
  PageModel<Orders> findPageByUid(String uid, int pageid);

  /**
   * 从redis中查看订单
   * @param key
   * @param filed
   * @return
   */
  Orders findOrderFromRedis(String key, String filed);

  /**
   * 删除订单
   * @param key
   * @param oid
   * @return
   */
  ServerResponse deleteorder(String key, String oid);

  /**
   * 删除所有订单
   * @param user
   * @param order
   * @return
   * @throws SQLException
   */
  void update(User user, Orders order) throws SQLException;

  /**
   * 添加order到队列
   * @param user
   * @param caritems
   * @return
   * @throws InterruptedException
   */
  ServerResponse<Orders> addorder(User user, List<Caritem> caritems) throws InterruptedException;

  /**
   * 创建一个临时订单
   * @param caritemList
   * @param user
   * @return
   */
  Orders createOrder(List<Caritem> caritemList, User user);


  /**
   * 创建一个临时 orderitem
   * @param pid
   * @param count
   * @return
   */
  List<Caritem> createOrderitem(String pid, String count);

  /**
   * 判断订单是否已经在数据库中
   * @param session
   * @throws IOException
   * @throws TimeoutException
   */
  void judgeandupdate(HttpSession session) throws IOException, TimeoutException;

  /**
   * 找到所有的订单（后台管理）
   * @param pageid
   * @param count
   * @return
   */
  PageModel<Orders> findAllOrder(Integer pageid, int count);


  /**
   * 发货
   * @param oid
   */
  void shipments(String oid);


  /**
   * 收货
   * @param user
   * @param oid
   */
  void confirm(User user,String oid);


  /**
   * 检查库存
   * @param pid
   * @param count
   * @return
   */
  boolean hasinventory(String pid,String  count);

  /**
   * 更新库存
   * @param orderitems
   * @param type
   */
  void updateinventory(List<Orderitems> orderitems,String type);
}
